<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

class ProductValidate extends CoreValidate {
	
	//constructor
	function ProductValidate() {
		
	}
	
	//methods
	function checkAddItem($data_array) {
		if( $this->_str_le($data_array['products_name'], 0) ) {
			$this->_add('products_name', 'Products Name is Null');
		} elseif( $this->_str_le($data_array['products_name'], 5) ) {
			$this->_add('products_name', 'Products Name is less than 5 characters');
		} elseif( $this->_str_gt($data_array['products_name'], 20) ) {
			$this->_add('products_name', 'Products Name is more than 20 characters');
		}
	}
	
	function checkUpdateItem($data_array) {
		if( $this->_str_le($data_array['products_name'], 0) ) {
			$this->_add('products_name', 'Products Name is Null');
		} elseif( $this->_str_le($data_array['products_name'], 5) ) {
			$this->_add('products_name', 'Products Name is less than 5 characters');
		} elseif( $this->_str_gt($data_array['products_name'], 20) ) {
			$this->_add('products_name', 'Products Name is more than 20 characters');
		}
	}
	
	//category
	function checkAddCategory($data_array) {
		if( $this->_str_le($data_array['categories_name'], 0) ) {
			$this->_add('categories_name', 'Categories Name is Null');
		} elseif( $this->_str_le($data_array['categories_name'], 5) ) {
			$this->_add('categories_name', 'Categories Name is less than 5 characters');
		} elseif( $this->_str_gt($data_array['categories_name'], 20) ) {
			$this->_add('categories_name', 'Categories Name is more than 20 characters');
		}
	}
	
	function checkUpdateCategory() {
		if( $this->_str_le($data_array['categories_name'], 0) ) {
			$this->_add('categories_name', 'Categories Name is Null');
		} elseif( $this->_str_le($data_array['categories_name'], 5) ) {
			$this->_add('categories_name', 'Categories Name is less than 5 characters');
		} elseif( $this->_str_gt($data_array['categories_name'], 20) ) {
			$this->_add('categories_name', 'Categories Name is more than 20 characters');
		}
	}
}
//
?>